class Solution:
    def letterCasePermutation(self, s):
        result = []

        def backtrack(index, current_string):
            if index == len(s):
                result.append("".join(current_string))
                return

            char = s[index]

            if '0' <= char <= '9':
                current_string.append(char)
                backtrack(index + 1, current_string)
                current_string.pop()
            else:
                current_string.append(char)
                backtrack(index + 1, current_string)
                current_string.pop()

                current_string.append(char.swapcase())
                backtrack(index + 1, current_string)
                current_string.pop()

        backtrack(0, [])
        return result